package com.mrper.ext.uibase;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.widget.PopupWindow;

import com.miguo.ui.R;
import com.mrper.util.CommonUtil;

/**
 * Created by admin on 2016/5/9.
 * 基本PopupWindow
 */
public class BasicPopupWindow<B extends ViewDataBinding> extends PopupWindow {

    protected Context context;
    protected B dataBinder;

    public BasicPopupWindow(Context context) {
        super();
        this.context = context;
        this.setAnimationStyle(getDialogAnimationId());
        this.setBackgroundDrawable(getWindowBackgroundDrawable());
        dataBinder = DataBindingUtil.inflate(LayoutInflater.from(context),
                CommonUtil.inflateContentView(this),null,false);
    }

    protected Drawable getWindowBackgroundDrawable(){
        return new ColorDrawable(Color.TRANSPARENT);
    }

    protected void finishInit(){
        this.setContentView(dataBinder.getRoot());
    }

    /** 获取默认的窗口动画 **/
    protected int getDialogAnimationId(){
        return  R.style.ActionSheetAnimationStyle;
    }


}
